import { BaseResultType } from '#/request'
import useDealResult from '@/hooks/dealResult'
import uniRequest from '@/request'

const { dealResult, checkResult } = useDealResult()
export const getUserStorageList = async (userId: string, type: string, createTimeStart: string, createTimeEnd: string): Promise<BaseResultType<any> | null> => {
  let param = `userId=${userId}&type=${type}`
  if (createTimeStart && createTimeStart && type == '5') {
    param += `&createTimeStart=${createTimeStart} 00:00:00&createTimeEnd=${createTimeEnd} 23:59:59`
  }
  const [result, err] = await uniRequest.get('/sh/api/getUserStorageList?' + param)
  return Promise.resolve(dealResult(err, result))
}



export const getDdHz = async (userId: string,  createTimeStart: string, createTimeEnd: string): Promise<BaseResultType<any> | null> => {
  let param = `userId=${userId}`
  if (createTimeStart && createTimeEnd ) {
    param += `&startTime=${createTimeStart}&endTime=${createTimeEnd}`
  }
  const [result, err] = await uniRequest.get('/sh/api/getDdHz?' + param)
  return Promise.resolve(dealResult(err, result))
}
